import {RESTfulResult} from '../http/restful-result.type';
import {ProvinceType} from "../model/province.type";
import {CityType} from "../model/city.type";
import {DistrictType} from "../model/district.type";
import {AreaType} from "../model/area.type";
import {request} from "../http/request";

export class QueryService {

    /** getAllProvinces */
    public static getAllProvinces(): Promise<RESTfulResult<Array<ProvinceType>>> {
        return request({
            method: 'get',
            url: '/query/getAllProvinces',
            data: null,
        })
    }

    /** getCitiesByProvinceAdcode */
    public static getCitiesByProvinceAdcode(data: {adcode: string}): Promise<RESTfulResult<Array<CityType>>> {
        return request({
            method: 'get',
            url: '/query/getCitiesByProvinceAdcode',
            data: data,
        })
    }

    /** getDistrictsByCityAdcode */
    public static getDistrictsByCityAdcode(data: {adcode: string}): Promise<RESTfulResult<Array<DistrictType>>> {
        return request({
            method: 'get',
            url: '/query/getDistrictsByCityAdcode',
            data: data,
        })
    }

    /** getAreaByAdcode */
    public static getAreaByAdcode(data: {adcode: string}): Promise<RESTfulResult<AreaType>> {
        return request({
            method: 'get',
            url: '/query/getAreaByAdcode',
            data: data,
        })
    }

}
